@extends('backstage.layout.master')
@section('title', '产品模板类型列表')
@section('content')
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a target="_blank" href="backstage/home">主页</a>
            </li>

            <li class="active">
                <a target="_blank" href="/backstage/product-temp/product-temp-category-list">产品模板类型</a>
            </li>
            <li>
                产品模板类型列表
            </li>
        </ul><!-- .breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
								<span class="input-icon">
									<input type="text" placeholder="搜索..." name="search" value="{{$product_temp_categorys->search}}" class="nav-search-input"
                                           id="nav-search-input" autocomplete="off"/>
									<i class="icon-search nav-search-icon"></i>
								</span>
            </form>
        </div><!-- #nav-search -->
    </div>

    <div class="page-content">
        <div class="page-header">
            <h1>
                产品模板类型
                <small>
                    <i class="icon-double-angle-right"></i>
                    产品模板类型列表
                </small>
                <span class="pull-right">
                    <button class="btn btn-primary" onclick="javascript:window.location.href='{{asset('')}}backstage/product-temp/add-product-temp-category';">添加类型</button>
                </span>
            </h1>

        </div>
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="table-responsive">
                    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <th class="center">
                                <label>
                                    <input type="checkbox" class="ace">
                                    <span class="lbl"></span>
                                </label>
                            </th>
                            <th>编号</th>
                            <th>名称</th>
                            <th>Ico</th>
                            <th class="hidden-480">分类描述</th>
                            <th>操作</th>
                        </tr>
                        </thead>

                        <tbody>
                        @foreach ($product_temp_categorys as $product_temp_category)
                        <tr class="" data-tr-id="{{$product_temp_category->id}}">
                            <td class="center">
                                <label>
                                    <input type="checkbox" class="ace">
                                    <span class="lbl"></span>
                                </label>
                            </td>
                            <td>{{isset($product_temp_category->id)?$product_temp_category->id:0}}</td>
                            <td>
                                {{isset($product_temp_category->name)?$product_temp_category->name:''}}
                            </td>
                            <td><img src="{{isset($product_temp_category->original_image)?$product_temp_category->original_image:''}}" width="100" ></td>
                            <td class="hidden-480">
                                {{isset($product_temp_category->description)?str_limit($product_temp_category->description, $limit = 20, $end = '...'):''}}
                            </td>

                            <td>
                                <ul class="nav-pills" style="list-style-type:none">
                                    <li class="dropdown all-camera-dropdown">
                                        <a style = "color: #2709ff" target="_blank" href="/backstage/product-temp/update-product-temp-category?id={{isset($product_temp_category->id)?$product_temp_category->id:0}}">
                                            <span id="" style="font-weight: bold">编辑</span>
                                        </a>
                                    </li>
                                    <li data-filter-camera-type="all">
                                        <a  data-delete="{{isset($product_temp_category->id)?$product_temp_category->id:0}}" style = "cursor:pointer;color: red;margin-left: 15px">
                                            <span style="font-weight: bold">删除</span>
                                        </a>
                                    </li>
                                </ul>
                            </td>
                        </tr>
                        @endforeach
                        </tbody>
                    </table>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="dataTables_info" id="sample-table-2_info"></div>
                    </div>
                    <div class="col-sm-6">
                        <div class="dataTables_paginate paging_bootstrap">
                            <?php echo $product_temp_categorys->render(); ?>
                        </div>
                    </div>
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
@stop
@section('script')
    <script type="text/javascript">
        $(function () {
            $('[data-rel=tooltip]').tooltip();
            $('table th input:checkbox').on('click' , function(){
                var that = this;
                $(this).closest('table').find('tr > td:first-child input:checkbox')
                        .each(function(){
                            this.checked = that.checked;
                            $(this).closest('tr').toggleClass('selected');
                        });

            });
            $('[data-delete]').click(function(){
                var  id = $(this).attr("data-delete");
                if(id!==0){
                    swal({
                        title: "确定删除？？",
                        text: "",
                        type: "warning",
                        showCancelButton: true,
                        confirmButtonColor: "#DD6B55",
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        closeOnConfirm: true,
                        closeOnCancel: true
                    },function (){
                        $.ajax({
                            type: "POST",
                            url: "/backstage/product-temp/del-temp-category",
                            data: {'id':id},
                            success: function (msg) {
                                if(msg.state==1){
                                    swal({title: "删除成功！", text: "",type: "success", timer:1000 })
                                    $('[data-tr-id='+id+']').remove();
                                }else {
                                    swal({title: msg.message, text: "",type: "error", timer:1000 })
                                }

                            }, error: function () {
                                swal({title: "系统繁忙！", text: "",type: "error", timer:1000 })
                            }
                        });
                    });
                }
            });
        });
    </script>
@stop